home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1991 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.3 KB  |  50 lines

  1. Path: news1.h1.usa.pipeline.com!usenet
  2. From: grantp@usa.pipeline.com(Pete)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: strings from VB
  5. Date: 14 Jan 1996 21:54:49 GMT
  6. Organization: Kalevi, Inc.
  7. Message-ID: <4dbu39$cj4@news1.usa.pipeline.com>
  8. NNTP-Posting-Host: pipe2.h1.usa.pipeline.com
  9. X-PipeUser: grantp
  10. X-PipeHub: usa.pipeline.com
  11. X-PipeGCOS: (Pete)
  12. X-Newsreader: Pipeline USA v3.3.0
  13.  
  14. On Jan 14, 1996 19:33:06 in article <strings from VB>, 'mgooding@wolfe.net
  15. (Joshua Gooding)' wrote: 
  16.  
  17.  
  18. >I am writing a DLL in Borland C++ that has several functions that I am  
  19. >going to call from a Visual Basic 3.0 Professional application but I need 
  20. >to pass a string to the function.  How would I go about doing this.  Does 
  21.  
  22. >Visual Basic pass strings as pointers to characters? 
  23.  
  24. This is really a VB question, but what the heck, C++ people might 
  25. want to know also. 
  26.  
  27. Given a DLL function declared as: 
  28.  
  29. extern "C" int WINAPI Foo (LPSTR s, int n); 
  30.  
  31. In VB module, write 
  32.  
  33. Declare Function Foo Lib "FOO.DLL" (Byval x as string, 
  34.                byval y as integer) as integer 
  35.  
  36. In your code write: 
  37.   dim xx as string * 25 
  38.   dim len as integer 
  39.   
  40.    len = Foo(xx, 25); 
  41.  
  42. Now, the DLL function can write to the string xx up to 
  43. 25 characters.  (24 if null terminated). 
  44.  
  45. Send e-mail if you want a sample. 
  46. -- 
  47. Pete Grant 
  48. Kalevi, Inc. 
  49. Object Oriented Software Development
  50.